var app=getApp();
var c=require('../common.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    focusinfo:false,
    hiddeninfo1: false,
    hiddeninfo2:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    this.setData({ options});
    var needtype = options.needtype;
    var inputvalue_textarea = options.inputvalue_textarea;
    this.setData({
      needtype: needtype,
      inputvalue_textarea: inputvalue_textarea
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  inputinfo:function(){
    this.setData({ focusinfo:true});
  },
  bindinputvalue:function(e){
    var money= e.detail.value;
    this.setData({ money: money})
  },
  submitinfo:function(){
    var money = this.data.money;
    if (typeof (money) == 'undefined') {
      wx.showToast({
        title: '请填写总预算',
        icon: 'none'
      })
      return;
    }
    this.setData({
      hiddeninfo1: true,
      hiddeninfo2: false
    })
  },
  submitinfo2:function(){
    var money = this.data.money;
    var cate_id = this.data.options.cate_id;
    var data = this.data.options.data;
    var index = this.data.options.index;
    var inputvalue_textarea = this.data.options.inputvalue_textarea;
    var inputvalue_time = this.data.options.inputvalue_time;
    var sendAudioList = this.data.options.sendAudioList;
    var time = this.data.options.time;
    var arrayimg = this.data.options.arrayimg;
    var longtime = this.data.options.longtime;
    var uid = this.data.options.uid;

    c.ajax(
      app.url +'sendneedadd',
      { money: money, cate_id: cate_id, data: data, index: index, inputvalue_textarea: inputvalue_textarea, inputvalue_time: inputvalue_time, sendAudioList: sendAudioList, time: time, arrayimg: arrayimg, longtime: longtime, uid: uid},
      res=>{
        wx.showToast({
          title: '上传成功',
          icon:'none'
        })
         if(res.data){
            setTimeout(function(){
              wx.navigateTo({
                url: '/pages/sendneedorder/sendneedorder?id=' + res.data.demand_id + '&order_id=' + res.data.order_id + '&order_num=' + res.data.order_num,
            })
            },2000);
         };
      }
    )
  }
})